package com.guigu.aws.demo01;

import java.io.File;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;

/**
 * Hello world!
 *
 */
public class S3UploadDirApp {

	private static String AWS_ACCESS_KEY = "AWS_ACCESS_KEY";
	private static String AWS_SECRET_KEY = "AWS_SECRET_KEY ";

//  上传文件到文件夹中
	public static void main(String[] args) {
		// 创建 s3 对象
		AmazonS3 s3 = new AmazonS3Client(new BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY));
		// 设置区域 ( 我们使用的是宁夏区域 )
		s3.setRegion(Region.getRegion(Regions.CN_NORTHWEST_1));
		// 上传文件到桶中
		File file = new File("C:\\Users\\86182\\Desktop\\问题.txt");
		// 桶名，文件夹名，本地问价路径
		s3.putObject("demo02", "img/wenti", file);
		System.out.println("上传成功...");
	}

}
